Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command line export for Tiled #318

Merged
merged 1 commit into from
Dec 2, 2014
Merged

Conversation

Noughtceratops
Copy link
Contributor

Hi! I'm a programmer over at Double Fine and we've been using Tiled to lay out levels for one of our Amnesia Fortnight prototypes. In order to integrate Tiled nicely into our build pipeline, we need the ability to transform tmx files to export formats on the command line. This change hacks some of that behavior into main.cpp. It lets us integrated Tiled into our build server.

Thought it might be of interest to you as well!

@jasonmcleod
Copy link

This is great! I just searched google for a method to export via command line for the same reason and didn't get very far.
Bumped over here to github, clicked issues, and bang.. first thing in the list!

Now i need to pull and build, and hopefully be able to add this to my build scripts also.

Thanks Thanks Thanks!

--edit--
having trouble building on OSX 10.8.2 :(

terminal is flooded with:

/usr/local/Cellar/qt/4.8.0/include/QtCore/qglobal.h:328:6: warning: #warning "This version of Mac OS X is unsupported"

@bjorn
Copy link
Member

bjorn commented Dec 6, 2012

@jasonmcleod Why use such an old version of Qt. Did you try with Qt 4.8.4? Or try the new Qt 5 RC. Tiled has so far not been tried with that version of Qt on OSX, but I'm curious whether it works.

@Earl-Brown
Copy link

Does this export method work with large maps? I have a 1200x600 map that won't export to image. Last I knew, the export failed because of a QT issue ... maybe this doesn't have that issue?

@bjorn
Copy link
Member

bjorn commented Dec 28, 2012

@Earl-Brown This is about exporting the map to one of the supported map formats, not about exporting to an image.

The only issue I could think of when trying to export a 1200x600 map to an image would be memory usage. It needs to be able to allocate enough memory for the entire image, and then write that to whatever file format you have in mind. Usually you wouldn't export a map 1:1 because the main point of using a tile map is avoiding that kind of memory usage, but rather export it at a smaller scale (just zoom out first and choose "Use current zoom level" in the Save As Image dialog).

Btw, since recently (in the dailies) there is a separate tool shipped with Tiled called "tmxrasterizer", which does basically the same thing as the Save As Image dialog. It has the same problem regarding image size, though.

@Earl-Brown
Copy link

Bummer for me that it's not for images. :(

But you're right about it being a memory issue. I don't remember what the issue really was, but I think it had to do with a max value for pointers in image manipulation.

I'm debating writing an image builder on my own. If only I didn't have 50 other projects in my to-do list :)

@eropple
Copy link

eropple commented Jan 17, 2013

Or try the new Qt 5 RC. Tiled has so far not been tried with that version of Qt on OSX, but I'm curious whether it works.

It'll start up (if you don't use the app bundle and invoke it directly), but crashes as soon as you try to do anything. =)

@bjorn
Copy link
Member

bjorn commented Jan 27, 2013

@cbdillon Btw, sorry for not commenting specifically on your change. I think the functionality is definitely wanted but I'm not sure about the exact arguments format and I don't like to have all that code directly in the main function. Also, I've been very busy while I tried to focus on getting a Tiled 0.9 release out. I'll look closely at this change once that is done.

@netguy204
Copy link

+1 on this change. I need this functionality for my asset pipeline as well.

@netguy204
Copy link

@bjorn I'm considering refactoring this into a stand-alone utility that's built alongside Tiled. How would you feel about that change?

@bjorn
Copy link
Member

bjorn commented Sep 4, 2013

@netguy204 Sounds fine to me, so go ahead!

@elisee
Copy link

elisee commented Sep 21, 2014

Was this ever merged or a commandline tool built for command line (JSON) export of maps?

@bjorn
Copy link
Member

bjorn commented Sep 21, 2014

@elisee Not yet, unfortunately.

@netguy204
Copy link

I solved my problem another way so this should go on without me.

@mieslep
Copy link

mieslep commented Nov 2, 2014

Any joy with this? It'd be super handy to have build tools and other things that can watch/auto-compile .tmx files into formats such as .json. Of course I need it for OSX not Windows .exe :)

@Earl-Brown
Copy link

I've given up on it - but one of these centurys, I'm going to build a web-based viewer.

@j3nda
Copy link

j3nda commented Nov 24, 2014

hi guys,
so this feature isn't merget into master@tiled yet. isn't it?! (or exists some exportOnlyTmxToPngUtility?)

(i'm developing some game with based maps on tiled. and this feature, like: "./tiled --export-image layers[2,3,4,5]" and similar :) it will be very helpfull for us. because we plan to have more than <= 10 maps. so, automatic batch scripting is right choice for us than manual clicking / save as image in tiled. it's very booring so...)

@JumpLink
Copy link

JumpLink commented Dec 2, 2014

+1 for more command line tools generally!
For me, it would be very useful to convert the maps to different formats (to make this process scriptable)

@bjorn
Copy link
Member

bjorn commented Dec 2, 2014

Because of the high demand I've decided to merge this change. I think the command line format is fine, though the documentation should be fixed according to @stefanbeller's comment and the error checking should probably be a bit more strict. I will clean up the code a bit later, as time allows.

I'm sorry that it has taken so long. I never planned for this, there's just continuously other things to do as well. I hope to still release a Tiled 0.11 this year and this feature should definitely be part of it.

bjorn added a commit that referenced this pull request Dec 2, 2014
Command line export for Tiled
@bjorn bjorn merged commit 091dcaa into mapeditor:master Dec 2, 2014
@j3nda
Copy link

j3nda commented Dec 3, 2014

hi there,
i tested this new feature, but after compilile from scratch (rev 2014-12-03, yesterday) it compile all code OK, but fails on plugin-lib-csv. Sorry for this spam, but i haven't actually more time to investigate this.

$ ./tiled --export-map /absolute/path/experiments/MAPY-LARGE/y/y.tmx ./y.png
or
$ ./tiled --export-map /absolute/path/experiments/MAPY-LARGE/y/y.tmx /tmp/y.png

Error: Plugin verification data mismatch in '/home/local/tmp/smid/SMAZ/src/tiled.git/build/lib/tiled/plugins/libcsv.so'
"Export syntax is --export-map "

on:

  • Linux sabayon 3.16.0-sabayon Add support for hexagonal maps #1 SMP Mon Oct 20 03:13:14 UTC 2014 x86_64 Intel(R) Core(TM) i7-4702MQ CPU @ 2.20GHz GenuineIntel GNU/Linux
  • gcc --version
    gcc (Gentoo Hardened 4.8.3 p1.1, pie-0.5.9) 4.8.3
  • qmake --version:
    QMake version 2.01a
    Using Qt version 4.8.5 in /usr/lib64/qt4

and in moc_csvplugin.cpp has right version, this one:
** Meta object code from reading C++ file 'csvplugin.h'
** Created by: The Qt Meta Object Compiler version 63 (Qt 4.8.5)

@bjorn
Copy link
Member

bjorn commented Dec 3, 2014

Usually I think this means the plugin was compiled with a different version of Qt than Tiled, but I still need to check this feature myself as well actually. I'll look at it as soon as possible (though this may take some days).

Note though, that this export map feature does not cover rendering the map to an image. It can only be used to convert the map to the different file formats supported by Tiled. To render a map to an image from the command line there is a tool called tmxrasterizer included with Tiled.

@j3nda
Copy link

j3nda commented Dec 3, 2014

ah! i see. ok. so i will try it with tmxrasterizer. thx.

@bjorn
Copy link
Member

bjorn commented Dec 3, 2014

65e5c11 should address the problems with the CSV plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.